/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package model.DAO;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import model.entities.BillItem;
import model.entities.RoomType;

/**
 *
 * @author Hieu.Nguyen
 */
public class BillItemDAO {
     private static BillItemDAO billItemDAO;

    public static BillItemDAO getInstance() {
        if (billItemDAO == null) {
            billItemDAO = new BillItemDAO();
        }
        return billItemDAO;
    }
    
     public List<BillItem> getBillItem(boolean isActived) {
        List<BillItem> listBillItem = new ArrayList<BillItem>();
        try {
            Connection conn = ConnectionFactory.getConnection();
            String sql = "select * from tblRoomType";
            PreparedStatement pstmt = conn.prepareStatement(sql);
            
            ResultSet rs = pstmt.executeQuery();
            while (rs.next()) {
                BillItem r = new BillItem();
                r.setBillItemID(rs.getInt("BillItemID"));
                r.setRoomID(rs.getInt("RoomID"));
                r.setBillItemTypeID(rs.getInt("RoomItemTypeID"));
                r.setBillItemDescription(rs.getString("RoomItemDescription"));
                r.setBillItemAmount(rs.getFloat("BillItemAmount"));
                r.setBillChargeDate(rs.getDate("BillChargeDate"));
                r.setDiscountID(rs.getInt("DiscountID"));
                r.setBillID(rs.getInt("BillID"));
                listBillItem.add(r);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return listBillItem;
    }
    
    
}
